<template>
  <div class="customer-third" v-loading="loading" element-loading-text="加载中...">
    <el-table border stripe :data="tableData">
      <el-table-column prop="name" label="分类名称" />
      <el-table-column prop="remark" label="说明" />
      <el-table-column label="启用" width="120" align="center">
        <template #default="scoped">
          <el-switch v-model="scoped.row.status" active-text="是" :active-value="1" inactive-text="否" :inactive-value="0"
            inline-prompt @change="statusFun(row)" />
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script setup>
import { listApi, addApi } from "@/plugins/api/customer/setup/third";
import { useCounterStore } from "@/stores/counter.js";
const store = useCounterStore();
let tableData = ref([]);
let loading = ref(false);
function getData() {
  loading.value = true;
  listApi()
    .then((data) => {
      tableData.value = data;

      loading.value = false;
    })
    .catch(() => {
      loading.value = false;
    });
}
function statusFun(row) {
  let obj = {
    attrs: tableData.value,
  };

  addApi(obj).then(() => {
    ElMessage({
      type: "success",
      message: "修改成功！",
    });
    getData();
  });
}
onMounted(() => {
  getData();
});
</script>
<style lang="scss" scoped></style>
